package com.acoffee.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.sql.SQLException;
import java.util.HashMap;

/**
 * @author acoffee
 * @create 2021-11-24 15:30
 */
@Controller
public class MyController {

    @RequestMapping(value = "/testException1")
    public String testException1() throws Exception {
        throw new Exception();
    }

    @RequestMapping(value = "/testException2")
    public String testException2() {
        //模拟异常
        int i = 10 / 0;
        return "success";
    }

    @RequestMapping(value = "/testException3")
    public String testException3() throws Exception {
        try {
            //模拟异常
            int i = 10 / 0;
            return "suceess";
        } catch (Exception e) {
            throw new SQLException("查找数据失败");
        }
    }
}
